/**
 * https://leetcode-cn.com/problems/assign-cookies
 * @param {number[]} g
 * @param {number[]} s
 * @return {number}
 */
 var findContentChildren = function(g, s) {
  g.sort((a, b) => a - b);
  s.sort((a, b) => a - b);
  let count = 0;
  let gp = 0;
  let sp = 0;
  while (gp < g.length && sp < s.length) {
      // match children and biscuit
      if (g[gp] <= s[sp]) {
          count++;
          sp++;
          gp++;
      } else {
          sp++;
      }
  }
  return count;
}
